/*
<<<<<<< HEAD
* ServerActions
*/
(function(my){
	/*
	if (Error.captureStackTrace && Object.defineProperty) {
	        var global = window;
	        Object.defineProperty(global, '__STACK__', {
				get: function () {
	                var old = Error.prepareStackTrace;
	                Error.prepareStackTrace = function (error, stack) {
	                    return stack;
	                };
	                var err = new Error();
	                Error.captureStackTrace(err, arguments.callee);
	                Error.prepareStackTrace = old;
	                return err.stack;
	            }
	        });

	        Object.defineProperty(global, '__LINE__', {
	            get: function () {
	                return __STACK__[1].getLineNumber();
	            }
	        });

	        Object.defineProperty(global, '__FILE__', {
	            get: function () {
	                return __STACK__[1].getFileName();
	            }
	        });
	    }
	*/
	function BaseClass(){}
	my.BaseClass = BaseClass;
	my.__defineSetter__('loggeron', function(logonvar){
		my._logon = logonvar;
		console.log('loggeron = ' + logonvar);
	});
	my.__defineGetter__('loggeron', function(){
		return my._logon;
	})
	my.__defineSetter__('log', function(str){
		if(my._logon)
			console.log(str);
	})
	function settings(){}
	settings.prototype.constructor = settings;
	my.settings = new settings;
	my.settings.method = 'post';
	my.settings.debug = true;
})(this);
(function(my){
// http://ihelppark.com:8080/TingCheDangServer/GetUserBaseInfo.action
var key = CryptoJS.enc.Utf8.parse("sdfgyuiedfoiu64d");
var Server = function(request)
{	
	this.baseurl = request;	
	log = 'call constructor of class ' + Server.name;
	log = 'baseurl: ' + request;
};
Server.prototype.constructor = Server;
Server.prototype.encode = function(word)
{
		var b64 = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(word));
		log = b64.toString();
       	var srcs = CryptoJS.enc.Utf8.parse(b64.toString());  
		// log = srcs.toString(CryptoJS.enc.Utf8);
        	var encrypted = CryptoJS.AES.encrypt(srcs, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});  
        	return encrypted.toString();
};
Server.prototype.decode = function(word)
{
        	var decrypt = CryptoJS.AES.decrypt(word, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});  
        	var u = CryptoJS.enc.Utf8.stringify(decrypt).toString();  
		return CryptoJS.enc.Base64.parse(u).toString(CryptoJS.enc.Utf8);
};
Server.prototype.init = function(){
	log = 'init '
};
var action = function(actionName){
	this.actionName = actionName;
};
action.prototype.init = function(){
	log = 'init';
}
action.prototype.validkey = {};
action.prototype.__defineGetter__('data', function(){
	var d = {};
	var err=[];
	for(var key in this.validkey)
	{
		var validval = user[key] || this.validkey[key];
		if(undefined == validval)
			err.push(key);
		else
		{
			if(typeof this.validkey[key] == 'object')
			{
				var vdefine = this.validkey[key];
				var val = vdefine.value || user[key];
				if(undefined == val)
					 err.push(key);
				else
				{
					switch(vdefine.mode)
					{
					case 'encode':
						d[vdefine.formName] = server.encode(val);
						break;
					default:
						d[vdefine.formName] = val;
						break;
					}
				}
			}else
				d[key] = validval
			
		}
						
	}
	if(err.length)
		throw('missing keys:' + err.join(','));
	return d;
});
Server.prototype.request = function(actionRequest, funcCallback){
	if(!(actionRequest instanceof action)) 
	{
		log = actionRequest;
		log = 'actionRequest is not a instance of action';
		return false;
	}
	log = 'request action:';
	log = actionRequest;
	var jsonString = JSON.stringify(actionRequest.data);
	log = jsonString;
	var encodeData = server.encode(jsonString);
	log = encodeData;
	if(settings.method == 'post'){
		log = 'post data';
		log = settings.baseurl + '/' + actionRequest.actionName + '.action';
		log = 'encodedata:' + encodeData;
		$.post(settings.baseurl + '/' + actionRequest.actionName + '.action', "EncedParams=" + encodeData, function(data, status){
		// return data should be {jsonString:'xxxxx'}
			log = status;
			log = data;
			if(!data) return;
			
			var decodeData = server.decode(data.jsonString);
			if(funcCallback)
			{
				funcCallback(JSON.parse(decodeData));
			}	
		}, 'json');
	}else if(settings.method == 'get'){
		$.get(settings.baseurl + '/' + actionRequest.actionName + '.action?EncedParams=' + encodeData, function(data, status){
		// return data should be {jsonString:'xxxxx'}
		log = status;
		if(!data) return;
		log = data;
		var decodeData = server.decode(data.jsonString);
			if(funcCallback)
			{
				funcCallback(JSON.parse(decodeData));
			}	
		});
	}	
};

my.server = new Server(settings.baseurl || 'http://ihelppark.com:8080/TingCheDangServer');
my.Action = action;

function User(){};
User.prototype = new BaseClass;
User.prototype.constructor = User;
my.User = User;
function Tools(){};
Tools.prototype = new BaseClass;
Tools.prototype.constructor = Tools;
my.Tools = Tools;
})(this);
=======
 * ServerActions
 */
(function (my) {
    /*
     if (Error.captureStackTrace && Object.defineProperty) {
     var global = window;
     Object.defineProperty(global, '__STACK__', {
     get: function () {
     var old = Error.prepareStackTrace;
     Error.prepareStackTrace = function (error, stack) {
     return stack;
     };
     var err = new Error();
     Error.captureStackTrace(err, arguments.callee);
     Error.prepareStackTrace = old;
     return err.stack;
     }
     });
     
     Object.defineProperty(global, '__LINE__', {
     get: function () {
     return __STACK__[1].getLineNumber();
     }
     });
     
     Object.defineProperty(global, '__FILE__', {
     get: function () {
     return __STACK__[1].getFileName();
     }
     });
     }
     */
    function BaseClass() {}
    my.BaseClass = BaseClass;
    my.__defineSetter__('loggeron', function (logonvar) {
        my._logon = logonvar;
        console.log('loggeron = ' + logonvar);
    });
    my.__defineGetter__('loggeron', function () {
        return my._logon;
    })
    my.__defineSetter__('log', function (str) {
        if (my._logon)
            console.log(str);
    })
    function settings() {}
    settings.prototype.constructor = settings;
    my.settings = new settings;
    my.settings.method = 'post';
    my.settings.debug = true;

})(this);
(function (my) {
// http://ihelppark.com:8080/TingCheDangServer/GetUserBaseInfo.action

    var key = CryptoJS.enc.Utf8.parse("sdfgyuiedfoiu64d");
    var Server = function (request)
    {
        this.baseurl = request;
        log = 'call constructor of class ' + Server.name;
        log = 'baseurl: ' + request;
    };
    Server.prototype.constructor = Server;
    Server.prototype.encode = function (word)
    {
        var b64 = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(word));
        log = b64.toString();
        var srcs = CryptoJS.enc.Utf8.parse(b64.toString());
        // log = srcs.toString(CryptoJS.enc.Utf8);
        var encrypted = CryptoJS.AES.encrypt(srcs, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
        return encrypted.toString();
    };
    Server.prototype.decode = function (word)
    {
        var decrypt = CryptoJS.AES.decrypt(word, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
        var u = CryptoJS.enc.Utf8.stringify(decrypt).toString();
        return CryptoJS.enc.Base64.parse(u).toString(CryptoJS.enc.Utf8);
    };

    Server.prototype.init = function () {
        log = 'init '
    };
    var action = function (actionName) {
        this.actionName = actionName;
    };
    action.prototype.init = function () {
        log = 'init';
    }
    action.prototype.userObject = undefined;
    action.prototype.validkey = {};
    action.prototype.__defineGetter__('data', function () {
        var d = {};
        var err = [];
        var tmpthis = this;
        if (tmpthis.userObject == undefined)
            return d;

        for (var key in this.validkey)
        {
            // log = 'action.' + key;
            var validval = tmpthis.userObject[key] || this.validkey[key];
            if (undefined == validval)
                err.push(key);
            else
            {
                if (typeof this.validkey[key] == 'object')
                {
                    var vdefine = this.validkey[key];
                    var val = vdefine.value || tmpthis.userObject[key];
                    if (undefined == val)
                        err.push(key);
                    else
                    {
                        switch (vdefine.mode)
                        {
                            case 'encode':
                                d[vdefine.formName] = server.encode(val);
                                // log = vdefine.formName + ' = ' + d[vdefine.formName];
                                break;
                            default:
                                d[vdefine.formName] = val;
                                // log = vdefine.formName + ' = ' + val;
                                break;
                        }
                    }
                } else
                {
                    d[key] = validval;
                    // log = key + ' = ' + validval;
                }

            }

        }
        if (err.length)
            throw('missing keys:' + err.join(','));
        return d;
    });
    Server.prototype.encoding = 'utf-8';
    Server.prototype.fromEncoding = 'utf-8';
    Server.prototype.request = function (actionRequest, funcCallback) {
        if (!(actionRequest instanceof action))
        {
            log = actionRequest;
            log = 'actionRequest is not a instance of action';
            return false;
        }
        log = 'request action:';
        log = actionRequest;
        var jsonString = JSON.stringify(actionRequest.data);
        log = jsonString;
        var encodeData = encodeURIComponent(server.encode(jsonString));
        log = encodeData;
        if (settings.method == 'post') {
            log = 'post data';
            log = settings.baseurl + '/' + actionRequest.actionName + '.action';
            log = 'encodedata:' + encodeData;
            $.post(settings.baseurl + '/' + actionRequest.actionName + '.action', "EncedParams=" + encodeData, function (data, status) {
                // return data should be {jsonString:'xxxxx'}
                //log = status;
                //log = data;
                if (!data)
                    return;

                var decodeData = server.decode(data.jsonString);
                // decodeData = new TextDecoder(server.encoding).decode(decodeData);
                // log = data.jsonString;
                // decodeData = dec('gbk', enc('iso-8859-2', decodeData));
                // log = decodeData;
                var parse = JSON.parse(decodeData);
                // 
                var parseData = parse;
                function parseObj(target, data){
                    for(var key in data)
                    {
                      if(typeof data[key] == "string")
                        {
                            target[key] = dec(server.encoding, enc(server.fromEncoding, data[key]));
                        }
                      else if(typeof data[key] == "object") 
                      {
                          parseObj(target[key], data[key]);
                      }
                      else
                          target[key] = data[key];                    
                    }
                }
                parseObj(parseData, parse);
                
                if (funcCallback)
                {
                    funcCallback(parseData);
                }
            }, 'json');
        } else if (settings.method == 'get') {
            $.get(settings.baseurl + '/' + actionRequest.actionName + '.action?EncedParams=' + encodeData, function (data, status) {
                // return data should be {jsonString:'xxxxx'}
                log = status;
                if (!data)
                    return;
                log = data;
                var decodeData = server.decode(data.jsonString);
                if (funcCallback)
                {
                    funcCallback(JSON.parse(decodeData));
                }
            });
        }
    };

    my.server = new Server(settings.baseurl || 'http://ihelppark.com:8080/TingCheDangServer');
    my.Server = Server;
    my.Action = action;

    function User() {}
    ;
    User.prototype = new BaseClass;
    User.prototype.constructor = User;
    my.User = User;
    function Tools() {}
    ;
    Tools.prototype = new BaseClass;
    Tools.prototype.constructor = Tools;
    my.Tools = Tools;
})(this);

>>>>>>> 8f1ea022b5713246e82c62242592626f70c398ab
